package com.jwds.digital.bios.business.core.infrastructure.dto.belt.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltRouteTargetHisReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltRouteTargetHisRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltRouteTargetHis;
import java.util.Objects;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * BeltRouteTargetHis DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-12-11
 */
public class BeltRouteTargetHisAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static BeltRouteTargetHis dto2entity(BeltRouteTargetHisReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    BeltRouteTargetHis entity = new BeltRouteTargetHis();
    entity.setFlowNo(dto.getFlowNo());
    entity.setFlowCode(dto.getFlowCode());
    entity.setFlowName(dto.getFlowName());
    entity.setFlowDistance(dto.getFlowDistance());
    entity.setTonPowerConsumption(dto.getTonPowerConsumption());
    entity.setWorkEfficiency(dto.getWorkEfficiency());
    entity.setTransportEfficiency(dto.getTransportEfficiency());
    entity.setHealthScore(dto.getHealthScore());
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static BeltRouteTargetHis dto2entity(BeltRouteTargetHisReqDTO dto, BeltRouteTargetHis entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getFlowNo())) {
      entity.setFlowNo(dto.getFlowNo());
    }
    if(Objects.nonNull(dto.getFlowCode())) {
      entity.setFlowCode(dto.getFlowCode());
    }
    if(Objects.nonNull(dto.getFlowName())) {
      entity.setFlowName(dto.getFlowName());
    }
    if(Objects.nonNull(dto.getFlowDistance())) {
      entity.setFlowDistance(dto.getFlowDistance());
    }
    if(Objects.nonNull(dto.getTonPowerConsumption())) {
      entity.setTonPowerConsumption(dto.getTonPowerConsumption());
    }
    if(Objects.nonNull(dto.getWorkEfficiency())) {
      entity.setWorkEfficiency(dto.getWorkEfficiency());
    }
    if(Objects.nonNull(dto.getTransportEfficiency())) {
      entity.setTransportEfficiency(dto.getTransportEfficiency());
    }
    if(Objects.nonNull(dto.getHealthScore())) {
      entity.setHealthScore(dto.getHealthScore());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static BeltRouteTargetHisRespVO entity2dto(BeltRouteTargetHis entity) {
    if (entity == null) {
      return null;
    }
    BeltRouteTargetHisRespVO dto = new BeltRouteTargetHisRespVO();
    dto.setId(entity.getId());
    dto.setFlowNo(entity.getFlowNo());
    dto.setFlowCode(entity.getFlowCode());
    dto.setFlowName(entity.getFlowName());
    dto.setFlowDistance(entity.getFlowDistance());
    dto.setTonPowerConsumption(entity.getTonPowerConsumption());
    dto.setWorkEfficiency(entity.getWorkEfficiency());
    dto.setTransportEfficiency(entity.getTransportEfficiency());
    dto.setHealthScore(entity.getHealthScore());
    dto.setCreateTime(entity.getCreateTime());
    dto.setModifyTime(entity.getModifyTime());
    dto.setCreateUser(entity.getCreateUser());
    dto.setModifyUser(entity.getModifyUser());
    return dto;
  }

}
